package local.app.servers;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import local.app.authentiction.AuthenticationLDAP;
import local.app.authentiction.AuthenticationRSA;

public class StandardServer extends Server implements AuthenticationRSA {
    private final String userName = AuthenticationRSA.userName;
    private final String password = AuthenticationLDAP.password;



    public StandardServer(String nameServer, String ipAddress) throws JSchException {
        super(nameServer, ipAddress);
        super.createSession(AuthenticationRSA.userName,
                AuthenticationRSA.pathToPrivateKey, AuthenticationLDAP.password);
    }

    @Override
    public Session setConfigAndReturnSession() throws JSchException {
        Session session = new JSch().getSession(userName, getIpAddress(), getPort());
        session.setPassword(password);
        session.setConfig("StrictHostKeyChecking", "no");
        return session;
    }

//    private void createSession () throws JSchException {
//        this.session = this.setConfigAndReturnSession(AuthenticationRSA.userName,
//                AuthenticationRSA.pathToPrivateKey, AuthenticationRSA.password);
//        if (session != null) {
//            System.out.println("Session is created");
//        }
//    }



}
